<?php

namespace app\admin\controller;
class Jobapply extends base
{
    //前置方法
    protected $beforeActionList = [
        'map'  =>  ['only'=>'index'],
    ];

    /**
     * 搜索
     */
    protected function map(){
        if ($this->request->isGet()) {
            $data = $this->request->param();
            $this->datas = array();
            if (!empty($data['start_time']) && !empty($data['end_time']) && (strtotime($data['start_time']) < strtotime($data['end_time']))) {
                $this->datas ['create_time'] = [
                    ['>', strtotime($data['start_time'])],
                    ['<', strtotime($data['end_time'])]
                ];
            }
            if (isset($data['status'])) {
                $this->datas ['status'] = $data['status'];
            }else{
                $this->datas ['status'] = ['<>','2'];
            }
            $this->datas['lang'] = cookie('think_var_admin');
        }
    }

    /**
     * 查看
     */
    public function read($id,$uid)
    {
        $this->model->save(['status' => '1'], ['id' => $id]);

        /*列表start*/
        $data = db('user')->alias('U')
            ->join('__RESUME__ c', 'c.uid= U.id')
            ->field('U.*,c.center,c.file')
            ->where('U.id', $uid)
            ->find();
        $this->assign([
            'data' => $data,
        ]);
        return $this->fetch();
    }

    /**
     * 将招聘者的信息删除
     */
    public function dolistsave()
    {
        $post = $this->request->post();
        if (empty($post['id'])) {
            return ajax_info('请选择项目！', 'index');
        }
        foreach ($post['id'] as $key) {
            switch ($post['inputtype']) {
                case 'del':
                    $data['status'] = '2';
                    $keys['id']=$key;
                    $this->model->update($data,$keys);
                    break;
            }
        }
        return ajax_info('操作成功！', 'index');
    }
}
